﻿<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html {width: 100%;height: 100%; margin:0;font-family:"微软雅黑";}#l-map{height:480px;width:100%;}
</style>
<style>
    body {
      background: #049b95;
      width: 100%;
      height: 100%;
    }

    select {
      background: transparent;
      border: 1px so40pxlid #fff;
      position:absolute;
      top: 430px;
      left: 390px;
      line-height: ;
      height: 30px;
      box-sizing: border-box;
      font-size: 15px;
      font-weight: bold;
      border-radius: 4px;
      color: #000;
      padding: 0 10px;
    }

    select option {
      background: rgb(193, 247, 244);
      color: rgb(36, 31, 31);
      font-size: 20px;
      font-weight: bold;
    }
    select option:checked {
      color: #fff;
      background: rgb(128, 64, 99);
    }
    input{
            width: 70px;
            height: 70px;
            border-radius: 50%;
            position: absolute;
            top: 400px;
            left: 500px;
            color: #ff8232;
            font-size: x-large;
            border: solid black;
            background: none;
      }

  </style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=9Y9FWqsWrfvHOyPjDQXXyeOehloOmlrW"></script>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<title>根据起终点名称查询公交换乘</title>
<script type="text/javascript" >
function callfromqt(start,end)
{
    // 百度地图API功能
   // var map = new BMap.Map("l-map");
    //添加放大缩小控件
    map.addControl(new BMap.NavigationControl());

    map.centerAndZoom(new BMap.Point(116.404, 39.915), 14);
    var routePolicy = [BMAP_TRANSIT_POLICY_LEAST_TIME,BMAP_TRANSIT_POLICY_LEAST_TRANSFER,BMAP_TRANSIT_POLICY_LEAST_WALKING,BMAP_TRANSIT_POLICY_AVOID_SUBWAYS];
    var transit = new BMap.TransitRoute(map, {
                    renderOptions: {map: map},
                    policy: 0
            });
    $("#result").click(function(){
            map.clearOverlays();
            var i=$("#driving_way select").val();
            search(start,end,routePolicy[i]);
            function search(start,end,route){
                    transit.setPolicy(route);
                    transit.search(start,end);
            }
    });
}
</script>
</head>
<body>
<div id="l-map"></div>
<div id="driving_way">
<select>
<option value="0">最少时间</option>
<option value="1">最少换乘</option>
<option value="2">最少步行</option>
<option value="3">不乘地铁</option>
</select>
<input type="button" id="result" value="查询"/>
</div>
</body>
</html>
<script type="text/javascript">
        // 百度地图API功能
        var map = new BMap.Map("l-map");
        map.centerAndZoom(new BMap.Point(116.404, 39.915), 14);
        map.addControl(new BMap.MapTypeControl());    //添加地图类型控件
        map.addControl(new BMap.NavigationControl()); // 添加平移缩放控件
        map.addControl(new BMap.ScaleControl());      // 添加比例尺控件
        var start = "天安门";
        var end = "北海公园";
        var routePolicy = [BMAP_TRANSIT_POLICY_LEAST_TIME,BMAP_TRANSIT_POLICY_LEAST_TRANSFER,BMAP_TRANSIT_POLICY_LEAST_WALKING,BMAP_TRANSIT_POLICY_AVOID_SUBWAYS];
        var transit = new BMap.TransitRoute(map, {
                        renderOptions: {map: map},
                        policy: 0
                });
        $("#result").click(function(){
                map.clearOverlays();
                var i=$("#driving_way select").val();
                search(start,end,routePolicy[i]);
                function search(start,end,route){
                        transit.setPolicy(route);
                        transit.search(start,end);
                }
        });
</script>
